package com.hz.pro.kitchen.dal.mapper;

import com.hz.pro.kitchen.dal.BasicMapper;
import com.hz.pro.kitchen.dal.entity.UserEntity;
import com.hz.pro.kitchen.dal.entity.UserEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface UserMapper extends BasicMapper<UserEntity> {
    @SelectProvider(type=UserEntitySqlProvider.class, method="countByExample")
    long countByExample(UserEntityExample example);

    @DeleteProvider(type=UserEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(UserEntityExample example);

    @Delete({
        "delete from T_User",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into T_User (id, userId, ",
        "userName, name, ",
        "sex, email, organizationId, ",
        "organizationName, siteId, ",
        "siteName, role, ",
        "mobile, passwordMd5, ",
        "created, updated)",
        "values (#{id,jdbcType=INTEGER}, #{userid,jdbcType=VARCHAR}, ",
        "#{username,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{sex,jdbcType=INTEGER}, #{email,jdbcType=VARCHAR}, #{organizationid,jdbcType=BIGINT}, ",
        "#{organizationname,jdbcType=VARCHAR}, #{siteid,jdbcType=BIGINT}, ",
        "#{sitename,jdbcType=VARCHAR}, #{role,jdbcType=INTEGER}, ",
        "#{mobile,jdbcType=VARCHAR}, #{passwordmd5,jdbcType=VARCHAR}, ",
        "#{created,jdbcType=TIMESTAMP}, #{updated,jdbcType=TIMESTAMP})"
    })
    int insert(UserEntity record);

    @InsertProvider(type=UserEntitySqlProvider.class, method="insertSelective")
    int insertSelective(UserEntity record);

    @SelectProvider(type=UserEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="userId", property="userid", jdbcType=JdbcType.VARCHAR),
        @Result(column="userName", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.INTEGER),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="organizationId", property="organizationid", jdbcType=JdbcType.BIGINT),
        @Result(column="organizationName", property="organizationname", jdbcType=JdbcType.VARCHAR),
        @Result(column="siteId", property="siteid", jdbcType=JdbcType.BIGINT),
        @Result(column="siteName", property="sitename", jdbcType=JdbcType.VARCHAR),
        @Result(column="role", property="role", jdbcType=JdbcType.INTEGER),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="passwordMd5", property="passwordmd5", jdbcType=JdbcType.VARCHAR),
        @Result(column="created", property="created", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updated", property="updated", jdbcType=JdbcType.TIMESTAMP)
    })
    List<UserEntity> selectByExample(UserEntityExample example);

    @Select({
        "select",
        "id, userId, userName, name, sex, email, organizationId, organizationName, siteId, ",
        "siteName, role, mobile, passwordMd5, created, updated",
        "from T_User",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="userId", property="userid", jdbcType=JdbcType.VARCHAR),
        @Result(column="userName", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.INTEGER),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="organizationId", property="organizationid", jdbcType=JdbcType.BIGINT),
        @Result(column="organizationName", property="organizationname", jdbcType=JdbcType.VARCHAR),
        @Result(column="siteId", property="siteid", jdbcType=JdbcType.BIGINT),
        @Result(column="siteName", property="sitename", jdbcType=JdbcType.VARCHAR),
        @Result(column="role", property="role", jdbcType=JdbcType.INTEGER),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="passwordMd5", property="passwordmd5", jdbcType=JdbcType.VARCHAR),
        @Result(column="created", property="created", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updated", property="updated", jdbcType=JdbcType.TIMESTAMP)
    })
    UserEntity selectByPrimaryKey(Integer id);

    @UpdateProvider(type=UserEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") UserEntity record, @Param("example") UserEntityExample example);

    @UpdateProvider(type=UserEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") UserEntity record, @Param("example") UserEntityExample example);

    @UpdateProvider(type=UserEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UserEntity record);

    @Update({
        "update T_User",
        "set userId = #{userid,jdbcType=VARCHAR},",
          "userName = #{username,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=INTEGER},",
          "email = #{email,jdbcType=VARCHAR},",
          "organizationId = #{organizationid,jdbcType=BIGINT},",
          "organizationName = #{organizationname,jdbcType=VARCHAR},",
          "siteId = #{siteid,jdbcType=BIGINT},",
          "siteName = #{sitename,jdbcType=VARCHAR},",
          "role = #{role,jdbcType=INTEGER},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "passwordMd5 = #{passwordmd5,jdbcType=VARCHAR},",
          "created = #{created,jdbcType=TIMESTAMP},",
          "updated = #{updated,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserEntity record);

    @Results(id = "tUserMap", value= {
        @Result(column="id", property="id", id=true),
        @Result(column="userId", property="userid"),
        @Result(column="userName", property="username"),
        @Result(column="organizationId", property="organizationid"),
        @Result(column="organizationName", property="organizationname"),
        @Result(column="siteId", property="siteid"),
        @Result(column="siteName", property="sitename"),
        @Result(column="passwordMd5", property="passwordmd5"),
    })
    @Select({
        "select ",
        "id, userId, userName, name, sex, email, organizationId, organizationName, siteId, ",
        "siteName, role, mobile, passwordMd5, created, updated",
        "from T_User"})
    List<UserEntity> selectAll();
}